class Solution(object):
    def numberToWords(self, num):
        """
        :type num: int
        :rtype: str
        """
        d1 = {'1': 'One', '2': 'Two', '3': 'Three', '4': 'Four', '5': 'Five', '6': 'Six', '7': 'Seven', '8': 'Eight',
              '9': 'Nine', '0': 'Zero'}
        d2 = {'10': 'Ten', '11': 'Eleven', '12': 'Twelve', '13': 'Thirteen', '14': 'Fourteen', '15': 'Fifteen',
              '16': 'Sixteen', '17': 'Seventeen', '18': 'Eighteen', '19': 'Nineteen'}
        d3 = {'2': 'Twenty', '3': 'Thirty', '4': 'Forty', '5': 'Fifty', '6': 'Sixty', '7': 'Seventy', '8': 'Eighty',
              '9': 'Ninety'}

        def convert_1(n):
            return d1[n]

        def convert_2(n):
            if n[0] == '0':
                return d1[n[1]]
            else:
                if n[0] == '1':
                    return d2[n]
                else:
                    if n[1] == '0':
                        return d3[n[0]]
                    else:
                        return d3[n[0]] + ' ' + d1[n[1]]

        def convert_3(n):
            if n == '000':
                return ''
            else:
                s = ''
                if n[0] == '0':
                    s += convert_2(n[1:])
                else:
                    if n[1:] != '00':
                        s = convert_1(n[0]) + ' Hundred ' + convert_2(n[1:])
                    else:
                        s = convert_1(n[0]) + ' Hundred'
                return s

        n = str(num)
        k = len(n) // 3
        d4 = {1: ' Thousand ', 2: ' Million ', 3: ' Billion '}
        index = 0
        s = ''
        while index < k:
            out = convert_3(n[len(n) - 3 * (index + 1): len(n) - 3 * index])
            if out:
                if index > 0:
                    s = out + d4[index] + s
                else:
                    s = out
            index += 1
        if len(n) - 3 * k == 1:
            out = convert_1(n[: len(n) - 3 * index])
            if index > 0:
                s = out + d4[index] + s
            else:
                s = out
        if len(n) - 3 * k == 2:
            out = convert_2(n[: len(n) - 3 * index])
            if index > 0:
                s = out + d4[index] + s
            else:
                s = out
        if s[-1] == ' ':
            s = s[: -1]
        return s


data = Solution()
num = 100000
print(data.numberToWords(num))
